<?php
include('common/constants.php');
include('common/msg_constants.php');
include('common/db.php');
session_start();

if (isset($_POST['email']) && isset($_POST['pass'])) {
	$sql = "select * from `user` where `email`='{$_POST['email']}' AND `password`='{$_POST['pass']}' AND activation_code='OK' ";
	//echo $sql;
	$result = mysql_query($sql) or trigger_error(mysql_error());
	$num_rows = mysql_num_rows($result);
	if($num_rows>0){
		$row = mysql_fetch_assoc($result);
		if ($row['email']!="" && $row['password']!="") {
			$_SESSION['user_name'] 	= $row['name'];
			$_SESSION['user_email']	= $row['email'];
			$_SESSION['user_type']	= $row['user_type'];
			//$_SESSION['user']="Administrator";
			echo "success";
		}else{
			echo "fail";
		}
	}else{
		$_SESSION['user']="";
		echo "fail";
	}
}else{
	echo "fail";
}